﻿@using DirigoEdge.Utils
@model DirigoEdge.Models.ViewModels.BlogSingleHomeViewModel
@{
    ViewBag.Title = Model.TheBlog.Title;
    ViewBag.MetaDesc = Model.TheBlog.MetaDescription;
    ViewBag.OGType = Model.TheBlog.OGType ?? "article";
    ViewBag.OGTitle = Model.TheBlog.OGTitle ?? Model.TheBlog.Title;
    ViewBag.OGImage = Model.TheBlog.OGImage ?? Model.TheBlog.OGImage;
}

<div class="singleBlogModule module">
    
    @* Breadcrumbs *@
    <div class="breadcrumbsContainer row">
        <div class="twelve columns">
            <ul class="breadcrumbs">
                <li>
                    <a href="/blog">
                        <span>Blog Home</span>
                    </a>
                </li>
                <li>
                    <a href="/blog/categories/@ContentUtils.GetFormattedUrl(Model.TheBlog.MainCategory)">
                        <span>@Model.TheBlog.MainCategory</span>
                    </a>
                </li>
                <li class="current">
                    <a href="/blog/@Model.TheBlog.PermaLink">@Model.TheBlog.Title</a>
                </li>
            </ul>
        </div>
    </div>

    <div class="row">
        @*Give admins a quick way to edit blog*@
        @{
            if (UserUtils.UserIsAdmin())
            {
                <a href="/Admin/EditBlog/@Model.TheBlog.BlogId" class="adminEdit" target="_blank">Edit</a>    
            }
        }
        
        @*Content Rail*@
        <div class="nine columns">
            <article>
                @* Blog Author *@
                @{
                    var user = "Anonymous";
                    var authorUrl = "#";
                    if (Model.TheBlogUser != null)
                    {
                        user = Model.TheBlogUser.Username;
                        authorUrl = Model.TheBlog.BlogAuthorUrl ?? "#";
                    }
                }
                <h3><a href="/blog/@Model.TheBlog.PermaLink">@Model.TheBlog.Title</a></h3>
                <h6>Written by <a href="@authorUrl">@user</a> on @Model.TheBlog.Date.ToLongDateString()</h6>
                
                @{
                    if (!String.IsNullOrEmpty(Model.TheBlog.ImageUrl))
                    {
                        <p>
                            <img src="@Model.TheBlog.ImageUrl" alt="@Model.TheBlog.Title" />    
                        </p>                        
                    }
             
                }
                <div class="row">
                    <div class="userBlogContent twelve columns">
                        @Html.Raw(Model.TheBlog.ShortDesc)
                    </div>
                </div>

                <div class="row">
                    <div class="userBlogContent twelve columns">
                        @Html.Raw(Model.TheBlog.HtmlContent)
                    </div>
                </div>
            </article>
            
            <hr/>
            
            @* Related Posts *@
            @Html.Partial("~/Views/Shared/Partials/RelatedPostsPartial.cshtml", Model.RelatedPosts)

            <hr/>
            
            @*== Facebook Like Button ==*@
            @{
                if (Model.ShowFacebookLikeButton)
                {
                    string absUrl = Model.BlogAbsoluteUrl;   
                    <div class="fbLikeContainer">
                        <iframe src="http://www.facebook.com/plugins/like.php?href=@absUrl" scrolling="no" frameborder="0" style="border: none; width: 450px; height: 80px"></iframe>
                    </div>
                }
            }
            
            @*== Disqus Comments ==*@
            @{
                if (Model.UseDisqusComments)
                {
                    <div class="disqusComments comments">
                        <div id="disqus_thread"></div>
                        <script type="text/javascript">
                            var disqus_shortname = '@Model.DisqusShortName'; // required

                            /* * * DON'T EDIT BELOW THIS LINE * * */
                            (function () {
                                var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
                                dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
                                (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
                            })();
                        </script>
                        <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
                        <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
                    </div>
                }
            }

            @*== Facebook Comments ==*@
            @{
                if (Model.ShowFacebookComments)
                {
                    <div class="fb-comments" data-href="@Model.BlogAbsoluteUrl" data-width="470" data-num-posts="10"></div>                    
                }
            }
            
        </div>
        
        @*Right Rail*@
        <div class="three columns blogPanels">
            
            @* Blog Author *@
            @Html.Partial("~/Views/Shared/Partials/BlogAuthorPartial.cshtml", Model.BlogAuthorModel)
            
            @* Categories *@
            @Html.Partial("~/Views/Shared/Partials/CategoriesListingPartial.cshtml", new DirigoEdge.Models.ViewModels.BlogsCategoriesViewModel(Model.TheBlog.MainCategory))
            
            @* Latest Blogs / Popular *@
            @Html.Partial("~/Views/Shared/Partials/PopularBlogsPartial.cshtml", new DirigoEdge.Models.ViewModels.BlogPopularViewModel())
            
            @* Archive *@
            @Html.Partial("~/Views/Shared/Partials/BlogArchivePartial.cshtml", new DirigoEdge.Models.ViewModels.BlogArchiveViewModel())

        </div>

    </div>

</div>

@section Meta {
    @{
        if (!String.IsNullOrEmpty(Model.TheBlog.Canonical))
        {
            <link rel="canonical" href="@Model.TheBlog.Canonical" />        
        }
    }
}